import request from '@/utils/request'

// 查询流程记录列表
export function listFlow(query) {
  return request({
    url: '/standard/flow/list',
    method: 'get',
    params: query
  })
}

// 查询流程记录详细
export function getFlow(id) {
  return request({
    url: '/standard/flow/' + id,
    method: 'get'
  })
}

// 新增流程记录
export function addFlow(data) {
  return request({
    url: '/standard/flow',
    method: 'post',
    data: data
  })
}

// 保存流程记录
export function saveFlow(data) {
  return request({
    url: '/standard/flow/save',
    method: 'post',
    data: data
  })
}

// 修改流程记录
export function updateFlow(data) {
  return request({
    url: '/standard/flow',
    method: 'put',
    data: data
  })
}

// 删除流程记录
export function delFlow(id) {
  return request({
    url: '/standard/flow/' + id,
    method: 'delete'
  })
}

// 导出流程记录
export function exportFlow(query) {
  return request({
    url: '/standard/flow/export',
    method: 'get',
    params: query
  })
}

// 根据部门+角色查询用户
export function selectOptions(userId, roleKey, deptName) {
  const data = {
    userId,
    roleKey,
    deptName
  }
  return request({
    url: '/standard/flow/selectOptions',
    method: 'get',
    params: data
  })
}

// 根据用户名 or 部门名称 or 角色名称查询用户
export function selectOptionsByNames(userName, deptName,roleName,postName) {
  const data = {
    userName,
    deptName,
    roleName,
    postName
  }
  return request({
    url: '/standard/flow/selectOptionsByNames',
    method: 'get',
    params: data
  })
}

// 根据项目ID和表名查询审批意见列表
export function listOpinion(nid,tableName) {
  const data = {
    nid,
    tableName
  }
  return request({
    url: '/standard/flow/listOpinion',
    method: 'get',
    params: data
  })
}
